package com.qf.dao;

import com.qf.pojo.entity.Seller;
import org.apache.ibatis.annotations.*;

/**
 * @ClassName SellerMapper
 * @Description TODO
 * @Author 非乐
 * @Date 2022/10/4 14:59
 * @Version 1.0
 **/
@Mapper
public interface SellerMapper {
//    根据用户名获取村存储对象
    @Results(id = "sellerMap",value = {
            @Result(column = "id",property = "id"),
            @Result(column = "username",property = "username"),
            @Result(column = "password",property = "password"),
            @Result(column = "email",property = "email"),
            @Result(column = "store_info_id",property = "storeInfoId")
    })
    @Select("select * from seller where username=#{username}")
    Seller findByName(String username);

//  根据邮箱获取存贮对象
    @ResultMap(value = "sellerMap")
    @Select("select * from seller where email=#{email}")
    Seller findByEmail(String email);

//   插入对象
    @Insert("insert into seller(username,password,email,store_info_id) values(#{username},#{password},#{email},#{storeInfoId})")
    int addSeller(Seller seller);

//    获取数据库店铺id的最大值
    @Select("select Max(store_info_id) from seller")
    int findMaxstoreInfoId();

}
